import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingCheckinMasterApi {
  /** 签到主信息 */
  export interface BookingCheckinMaster {
    id: number; // 签到主表ID
    checkinCode?: string; // 签到编码
    checkinType?: string; // 签到类型
    bookingOrderId: number; // 关联预约订单ID
    groupId: number; // 关联团体ID
    groupName: string; // 团体名称
    groupType: string; // 团体类型
    groupSize: number; // 团体总人数
    groupLeaderId: number; // 团体负责人ID
    groupLeaderName: string; // 团体负责人姓名
    expectedArrivalTime: string | Dayjs; // 预计到店时间
    firstArrivalTime: string | Dayjs; // 首个成员到店时间
    lastArrivalTime: string | Dayjs; // 最后成员到店时间
    lateArrivalTolerance: number; // 迟到容忍时间(分钟)
    checkinStatus?: string; // 签到状态
    arrivedCount: number; // 已到店人数
    totalCount: number; // 总人数
    noShowCount: number; // 未到店人数
    conversionStatus: string; // 转换状态
    conversionTime: string | Dayjs; // 转换时间
    conversionUserId: number; // 转换操作人ID
    checkinSource?: string; // 签到来源
    sourceChannel: string; // 来源渠道
    checkinNotes: string; // 签到备注
    storeId?: number; // 门店ID
    orgId?: number; // 组织ID
  }
}

/** 查询签到主分页 */
export function getBookingCheckinMasterPage(params: PageParam) {
  return requestClient.get<PageResult<BookingCheckinMasterApi.BookingCheckinMaster>>('/spa/booking-checkin-master/page', { params });
}

/** 查询签到主详情 */
export function getBookingCheckinMaster(id: number) {
  return requestClient.get<BookingCheckinMasterApi.BookingCheckinMaster>(`/spa/booking-checkin-master/get?id=${id}`);
}

/** 新增签到主 */
export function createBookingCheckinMaster(data: BookingCheckinMasterApi.BookingCheckinMaster) {
  return requestClient.post('/spa/booking-checkin-master/create', data);
}

/** 修改签到主 */
export function updateBookingCheckinMaster(data: BookingCheckinMasterApi.BookingCheckinMaster) {
  return requestClient.put('/spa/booking-checkin-master/update', data);
}

/** 删除签到主 */
export function deleteBookingCheckinMaster(id: number) {
  return requestClient.delete(`/spa/booking-checkin-master/delete?id=${id}`);
}


/** 导出签到主 */
export function exportBookingCheckinMaster(params: any) {
  return requestClient.download('/spa/booking-checkin-master/export-excel', { params });
}

